/**
 * author:Administrator
 * date:2016/1/9
 * desc:TODO
 */
'use strict';
var app = require('koa')();
var proxy = require('koa-proxy');

var httpPort = 9999;

// ---enable cross domain
var cors = require('koa-cors'); //解决跨域
app.use(cors({credentials: true}));

app.use(require('./router/pre_handler.js'));// logger here
app.use(require('./router/registry.js'));
app.use(require('./router/proxy.js'));


// static file
//var serve = require('koa-static');
//app.use(serve(__dirname + '/static'));

// 404
app.use(function*() {
  this.status = 404;
  this.body = '~~~404 not found~~~';
});


app.listen(httpPort, function () {
  console.log('server listen at localhost:%s', httpPort);
});